<template>
  <list-data ref="ListData" @remove-item="removeBtnClick" :status="1">
    <template slot="option" slot-scope="scope">
      <el-button type="text" size="small" @click="restoreBtnClick(scope.model)">恢复</el-button>
    </template>
  </list-data>
</template>

<script lang="ts">
  import {Vue, Component, Prop} from 'vue-property-decorator'
  import ListData from '@/components/data/array/com/list/index.vue'
  import DataModel from "@/models/DataModel";
  import YBPopView from "@/utils/popView";
  import { ListComType } from '@/components/data/array/com/list/types'

  @Component({
    components: {
      ListData
    }
  })
  export default class DataArray extends Vue {

    reloadData() {
      (this.$refs.ListData as ListComType).reloadData()
    }

    // 删除
    removeBtnClick(model: DataModel) {
      model.removeDataWithRecord().then(() => {
        YBPopView.msgSuccess('删除成功')
        this.reloadData()
      })
    }

    restoreBtnClick(model: DataModel) {
      YBPopView.confirm('提示', '确定要恢复吗？').then(() => {
        model.arrayListRecyclePop().then(() => {
          YBPopView.msgSuccess('恢复成功')
          this.reloadData()
        })
      })
    }
  }

</script>

<style scoped lang="scss">

</style>
